package net.qunzhi.modules.cms.service.impl;

import net.qunzhi.modules.cms.query.StateDateQuery;
import org.springframework.stereotype.Service;
import net.qunzhi.common.utils.BaseQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.Query;

import net.qunzhi.modules.cms.dao.TbElectricityStateDao;
import net.qunzhi.modules.cms.entity.TbElectricityStateEntity;
import net.qunzhi.modules.cms.service.TbElectricityStateService;


@Service("tbElectricityStateService")
public class TbElectricityStateServiceImpl extends ServiceImpl<TbElectricityStateDao, TbElectricityStateEntity> implements TbElectricityStateService {

    @Override
    public PageUtils queryPage(StateDateQuery query) {
        IPage<TbElectricityStateEntity> page = this.page(
                new Query<TbElectricityStateEntity>().getPage(query),
                new QueryWrapper<TbElectricityStateEntity>()
                        .eq("equipment_id", query.getEquipmentId())
                        .le("time", query.getEndDateTime())
                        .ge("time", query.getStartDateTime())
                        .orderByDesc("time")
        );

        return new PageUtils(page);
    }

}